home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / global / tow_dm.scr < prev    next >
Encoding:
Text File  |  2002-10-31  |  9.3 KB  |  423 lines

  1. //
  2. //
  3. //    Logic for Tug of War Based games
  4. main:
  5.  
  6.     // spawn an actor to make sure we cache in all of our animations for TOW maps
  7.     local.dummyactor = spawn "models/human/allied_pilot.tik" origin (0 0 0)
  8.     local.dummyactor hide
  9.     local.dummyactor notsolid
  10.     local.dummyactor ai_off
  11.  
  12. end
  13.  
  14.  
  15. //-----------------------------------------------
  16. // initialization thread... 
  17. //-----------------------------------------------
  18. bomb_thinker local.planting_team local.relay:
  19.  
  20. // Steve says planting time = 6 seconds
  21. // defusing time = 12 second
  22. // tick time = 36 seconds
  23.  
  24.     level.bomb_defuse_time        = 60        //tenths of a second
  25.     level.bomb_set_time            = 50        //tenths of a second
  26.     level.bomb_tick_time        = 15        //seconds (was 60 seconds, then 30 seconds)
  27.     level.bomb_explosion_radius    = 1054        //quake units
  28.     level.bomb_use_distance        = 128        //quake units
  29.     level.bomb_damage            = 200
  30.     level.bombusefov            = 30    
  31.  
  32.     level.planter                = NULL
  33.  
  34.     level.StopBomb                = 0
  35.  
  36.     level.subtitleX                = 100
  37.     level.subtitleY                = 50
  38.  
  39.     self.exploded                = 0
  40.  
  41.     self.planting_team = local.planting_team
  42.     if( self.planting_team == "allies" )
  43.     {
  44.         self.defusing_team = "axis"
  45.     }
  46.     else
  47.     {
  48.         self.defusing_team = "allies"
  49.     }
  50.  
  51.     self.relay = local.relay
  52.  
  53.     println "----------------------Z-----------------------"
  54.     println "self.planting_team = " self.planting_team
  55.     println "self.defusing_team = " self.defusing_team
  56.     println "self = " self
  57.     println "self.target (flak 88 or other) = " self.target
  58.     println "self.target.destroyed_model = " self.target.destroyed_model
  59.     println "self.target.target (collision entity) = " self.target.target
  60.     println "self.trigger_name = " self.trigger_name
  61.     println "self.exploder_set = " self.exploder_set
  62.     println "self.explosion_fx = " self.explosion_fx
  63.     println "self.explosion_sound = " self.explosion_sound
  64.     println "self.killarea = " self.killarea
  65.     println "self.relay = " self.relay
  66.     println "----------------------Z-----------------------"
  67.     
  68.     self.target.collisionent = self.target.target
  69.     self.target notsolid
  70.     thread bomb_waittill_set
  71.  
  72. end
  73.  
  74. //-----------------------------------------------
  75. //first thread... controls allies using the trigger
  76. //-----------------------------------------------
  77. bomb_waittill_set:
  78.  
  79.     self model items/pulse_explosive.tik
  80.     local.tickIndex = 0
  81.  
  82.     while ( $(self.trigger_name) )
  83.     {
  84.         println "waittill trigger " self.trigger_name 
  85.         self.trigger_name waittill trigger
  86.  
  87.         local.player = parm.other
  88.         
  89.         //"local.player.dmteam", can be 'spectator', 'freeforall', 'allies' or 'axis'    
  90.         if (local.player.dmteam != self.planting_team) 
  91.         {
  92.             goto bomb_waittill_set
  93.             println "failed dmteam check" local.player.dmteam    
  94.         }
  95.         
  96.         local.counter = 0
  97.         while ( (Isalive local.player) && (local.player cansee self level.bombusefov level.bomb_use_distance) && (local.player.useheld == 1) && (level.StopBomb == 0) )
  98.         {
  99.             if (local.counter == 0)
  100.             {
  101.                 local.player stopwatch (level.bomb_set_time * .1)
  102.             }
  103.                 
  104.             local.counter++
  105.             if( (local.counter % 10) == 0 )
  106.             {
  107.                 switch( local.tickIndex )
  108.                 {
  109.                 case 0:
  110.                     self playsound bomb_prime1
  111.                     break;
  112.                 case 1:
  113.                     self playsound bomb_prime2
  114.                     break;
  115.                 case 2:
  116.                     self playsound bomb_prime3
  117.                     break;
  118.                 case 3:
  119.                     self playsound bomb_prime4
  120.                     break;
  121.                 case 4:
  122.                     self playsound bomb_prime5
  123.                     break;
  124.                 case 5:
  125.                     self playsound bomb_prime6
  126.                     break;
  127.                 }
  128.  
  129.                 local.tickIndex++
  130.             }
  131.         
  132.             wait .1
  133.             if (local.counter >= level.bomb_set_time)
  134.             {
  135.                 if( local.player.dmteam == "allies" )
  136.                 {
  137.                     iprintlnbold "The Allies have Planted a Bomb!"
  138.                 }
  139.                 else if( local.player.dmteam == "axis" )
  140.                 {
  141.                     iprintlnbold "The Axis have Planted a Bomb!"
  142.                 }
  143.                 else
  144.                 {
  145.                     iprintlnbold "A Bomb has been Planted!"
  146.                 }
  147.  
  148.                 if (local.planting_team == "allies")
  149.                 {
  150.                     self playsound dfr_objective_o
  151.                 }
  152.                 else
  153.                 {
  154.                     self playsound den_objective_o
  155.                 }
  156.  
  157.                 //remember who planted the bomb
  158.                 level.planter = local.player
  159.  
  160.                 thread bomb_waittill_defuse
  161.                 thread bomb_waittill_explode
  162.                 self.live = 1
  163.                 
  164.                 end
  165.             }
  166.         }
  167.         
  168.         if (local.counter > 0)
  169.         {
  170.             local.player stopwatch 0
  171.         }
  172.         
  173.         println "usetrigger but failed check" 
  174.         
  175.         if ! (self cansee local.player level.bombusefov  level.bomb_use_distance) 
  176.         {
  177.             println "failed cansee check"    
  178.         }
  179.         
  180.         if ! (local.player.useheld == 1)
  181.         {
  182.             println "failed useheld check" local.player.useheld
  183.         }
  184.     }
  185.  
  186. end
  187.  
  188.  
  189. //-----------------------------------------------
  190. // second thread... controls axis using the trigger
  191. //-----------------------------------------------
  192. bomb_waittill_defuse:
  193.  
  194.     while ( $(self.trigger_name) )
  195.     {
  196.         self.trigger_name waittill trigger
  197.  
  198.         local.player = parm.other
  199.         
  200.         //"local.player.dmteam", can be 'spectator', 'freeforall', 'allies' or 'axis'
  201.         if (local.player.dmteam != self.defusing_team)
  202.         {      
  203.             println "failed dmteam check" local.player.dmteam
  204.             goto bomb_waittill_defuse
  205.         }
  206.         
  207.         
  208.         local.counter = 0
  209.         while ( (Isalive local.player) && (local.player cansee self level.bombusefov  level.bomb_use_distance) && (local.player.useheld == 1) && (self.exploded != 1) )
  210.         {
  211.             if (local.counter == 0)
  212.             {
  213.                 local.player stopwatch (level.bomb_defuse_time * .1)
  214.             }
  215.                 
  216.             local.counter++
  217.  
  218.             wait .1
  219.             if (local.counter >= level.bomb_defuse_time)
  220.             {
  221.                 if( local.player.dmteam == "allies" )
  222.                 {
  223.                     iprintlnbold "The Allies have Defused a Bomb!"
  224.                 }
  225.                 else if( local.player.dmteam == "axis" )
  226.                 {
  227.                     iprintlnbold "The Axis have Defused a Bomb!"
  228.                 }
  229.                 else
  230.                 {
  231.                     iprintlnbold "A Bomb has been Defused!"
  232.                 }
  233.                 
  234.                 
  235.                 if (self.defusing_team == "allies")
  236.                 {
  237.                     self playsound dfr_diffused_d
  238.                 }
  239.                 else
  240.                 {
  241.                     self playsound den_diffused_d
  242.                 }
  243.  
  244.                 level.planter = NULL
  245.                 
  246.                 //start first thread again                
  247.                 thread bomb_waittill_set                
  248.                 self.live = 0
  249.                 end
  250.             }
  251.         }
  252.  
  253.         if (local.counter > 0)
  254.         {
  255.             local.player stopwatch 0
  256.         }
  257.     }
  258.  
  259. end
  260.  
  261.  
  262. //-----------------------------------------------
  263. // third thread... times the bomb and makes it explode at the right time
  264. //-----------------------------------------------
  265. bomb_waittill_explode:
  266.  
  267.     self model items/explosive.tik
  268.     self playsound plantbomb
  269.  
  270.     self loopsound bombtick1
  271.     
  272.     local.start_time = level.time
  273.     while (level.time < (local.start_time + level.bomb_tick_time) && (level.StopBomb == 0) )
  274.     {
  275.         wait .1
  276.         if (self.live != 1)
  277.         {
  278.             self stoploopsound
  279.             end
  280.         }
  281.         if (level.time == (local.start_time + level.bomb_tick_time - 10) )
  282.         {
  283.             self stoploopsound
  284.             self loopsound final_countdown
  285.         }
  286.      }
  287.  
  288.     self stoploopsound
  289.  
  290.     if( level.StopBomb == 0 )
  291.     {             
  292.         thread bomb_explode
  293.     }
  294.  
  295.  
  296. end
  297.  
  298.  
  299. //-----------------------------------------------
  300. // fourth thread... controls the explosion 
  301. //-----------------------------------------------
  302. bomb_explode:
  303.     
  304.     self.trigger_name remove
  305.  
  306.     thread jitter_large 0
  307.     
  308.     if (self.exploder_set != NIL)
  309.     {
  310.         exec global/exploder.scr::explode self.exploder_set
  311.     }
  312.     
  313.     if (self.explosion_fx != NIL)
  314.     {
  315.         self thread spawn_fx self.explosion_fx
  316.     }
  317.     
  318.     if (self.explosion_sound != NIL)
  319.     {
  320.         self playsound self.explosion_sound
  321.     }
  322.  
  323.     if (self.target != NIL)
  324.     {
  325.         self.target thread blow_up
  326.         
  327.         waitframe
  328.     }
  329.     
  330.     radiusdamage (self.origin + (0 0 128)) level.bomb_damage level.bomb_explosion_radius
  331.         
  332.     if (self.killarea != NIL)
  333.     {
  334.         self.killarea volumedamage 1000
  335.     }
  336.     
  337.     self hide
  338.  
  339.     self.live = 0
  340.     
  341.     self.exploded = 1
  342.     level.targets_destroyed = level.targets_destroyed + 1
  343.  
  344.     // we delay the decrementing of    level.bombs_planted so that the script has
  345.     // time to determin the winner before the timelimit gets checked and hit
  346.     wait 0.5    
  347.     
  348. //    trigger self.relay
  349.     println "Bomb explode.. Calling relay thread!"
  350.     waitthread self.relay level.planter
  351.  
  352. end
  353.  
  354.  
  355. //-----------------------------------------------
  356. //Do some fx
  357. //-----------------------------------------------
  358. spawn_fx local.fx:
  359.  
  360.     local.temp = spawn script_model model local.fx
  361.     local.temp.origin = self.origin
  362.     local.temp anim start
  363.     wait 5
  364.     local.temp remove
  365.  
  366. end
  367.  
  368.  
  369. //-----------------------------------------------
  370. //Do some fx
  371. //-----------------------------------------------
  372. spawn_damaged local.model:
  373.  
  374.     local.damaged = spawn script_model model local.model
  375.     local.damaged.origin = self.origin
  376.     local.damaged.angles = self.angles
  377.  
  378. end local.damaged
  379.  
  380. //-----------------------------------------------
  381. // jitter large effect
  382. // jitter_large [delay]
  383. //-----------------------------------------------
  384. jitter_large local.time:
  385.     
  386.     if (local.time)
  387.         wait local.time
  388.  
  389.     waitexec global/earthquake.scr .35 10 0 0
  390.     waitexec global/earthquake.scr .23 6 0 0
  391.     waitexec global/earthquake.scr 1 1 0 0
  392.     waitexec global/earthquake.scr 1.25 .3 0 1
  393.  
  394. end
  395.  
  396.  
  397. //-----------------------------------------------
  398. //Blow up a thing
  399. //-----------------------------------------------
  400. blow_up:
  401.  
  402.     if (self.destroyed_model != NIL)
  403.     {
  404.         local.damaged = self thread spawn_damaged self.destroyed_model
  405.     }
  406.     
  407.     if( self.target != NIL )
  408.     {
  409.         self.target thread blow_up
  410.     }
  411.     self remove
  412.  
  413. end
  414.  
  415.  
  416. //-----------------------------------------------
  417. //Stop the bomb!
  418. //-----------------------------------------------
  419. StopBomb:
  420.  
  421.     level.StopBomb = 1
  422.  
  423. end